Index: lib/libz/infblock.c
===================================================================
RCS file: /home/ncvs/src/lib/libz/infblock.c,v
retrieving revision 1.2
diff -u -r1.2 infblock.c
--- lib/libz/infblock.c	30 Sep 2001 22:39:00 -0000	1.2
+++ lib/libz/infblock.c	17 Feb 2002 15:19:53 -0000
@@ -252,10 +252,11 @@
                              &s->sub.trees.tb, s->hufts, z);
       if (t != Z_OK)
       {
-        ZFREE(z, s->sub.trees.blens);
         r = t;
-        if (r == Z_DATA_ERROR)
+        if (r == Z_DATA_ERROR) {
+          ZFREE(z, s->sub.trees.blens);
           s->mode = BAD;
+	}
         LEAVE
       }
       s->sub.trees.index = 0;
@@ -316,11 +317,12 @@
         t = inflate_trees_dynamic(257 + (t & 0x1f), 1 + ((t >> 5) & 0x1f),
                                   s->sub.trees.blens, &bl, &bd, &tl, &td,
                                   s->hufts, z);
-        ZFREE(z, s->sub.trees.blens);
         if (t != Z_OK)
         {
-          if (t == (uInt)Z_DATA_ERROR)
+          if (t == (uInt)Z_DATA_ERROR) {
+            ZFREE(z, s->sub.trees.blens);
             s->mode = BAD;
+	}
           r = t;
           LEAVE
         }
@@ -332,6 +334,7 @@
         }
         s->sub.decode.codes = c;
       }
+      ZFREE(z, s->sub.trees.blens);
       s->mode = CODES;
     case CODES:
       UPDATE
Index: sys/net/zlib.c
===================================================================
RCS file: /home/ncvs/src/sys/net/zlib.c,v
retrieving revision 1.10
diff -u -r1.10 zlib.c
--- sys/net/zlib.c	29 Dec 1999 04:38:38 -0000	1.10
+++ sys/net/zlib.c	17 Feb 2002 15:19:53 -0000
@@ -3864,10 +3864,11 @@
                              &s->sub.trees.tb, z);
       if (t != Z_OK)
       {
-        ZFREE(z, s->sub.trees.blens);
         r = t;
-        if (r == Z_DATA_ERROR)
+        if (r == Z_DATA_ERROR) {
+          ZFREE(z, s->sub.trees.blens);
           s->mode = BADB;
+        }
         LEAVE
       }
       s->sub.trees.index = 0;
@@ -3932,11 +3933,12 @@
 #endif
         t = inflate_trees_dynamic(257 + (t & 0x1f), 1 + ((t >> 5) & 0x1f),
                                   s->sub.trees.blens, &bl, &bd, &tl, &td, z);
-        ZFREE(z, s->sub.trees.blens);
         if (t != Z_OK)
         {
-          if (t == (uInt)Z_DATA_ERROR)
+          if (t == (uInt)Z_DATA_ERROR) {
+            ZFREE(z, s->sub.trees.blens);
             s->mode = BADB;
+          }
           r = t;
           LEAVE
         }
@@ -3953,6 +3955,7 @@
         s->sub.decode.tl = tl;
         s->sub.decode.td = td;
       }
+      ZFREE(z, s->sub.trees.blens);
       s->mode = CODES;
     case CODES:
       UPDATE
